package domain.valueObejcts;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@SequenceGenerator(name = "floor_seq", sequenceName = "floor_id_seq")
public class Floor implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	private String name;
	private transient String date;
	@OneToMany(mappedBy = "floor")
	private List<Location> locations;
	
	public Floor(){
		this.id = 0;
	}
	
	public Floor(String name, String date) {
		this.name = name;
		this.date = date;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}
	
	@Override
	public boolean equals(Object obj) throws ClassCastException{
		if(obj instanceof Floor){
			if(((Floor)obj).getId() == this.id){
				return true;
			}
			return false;
		} else {
			throw new ClassCastException();
		}
	}

}
